<template>
  <div>
    <el-form :model="queryParam" :inline=true style="display: flex">
      <el-form-item label="产品">
        <el-input v-model="queryParam.productCode" style="width:160px"/>
      </el-form-item>
      <el-form-item label="名称">
        <el-input v-model="queryParam.name" style="width:160px"/>
      </el-form-item>
      <el-form-item label="手机号">
        <el-input v-model="queryParam.phoneNo" style="width:160px"/>
      </el-form-item>
      <el-form-item label="身份证">
        <el-input v-model="queryParam.idCard" style="width:160px"/>
      </el-form-item>
      <el-form-item label="银行卡号">
        <el-input v-model="queryParam.bankCard" style="width:160px"/>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="queryPage">搜索</el-button>
      </el-form-item>
    </el-form>
    <el-table :data="tableData" stripe style="width: 100%">
      <el-table-column label="会话" width="300">
        <template slot-scope="scope">
          <div class="typeEnter">时间：{{ parseTime(scope.row.createTime) }}</div>
          <div class="typeEnter">sid：{{ scope.row.sessionId }}</div>
        </template>
      </el-table-column>
      <el-table-column label="产品" width="100">
        <template slot-scope="scope">
          <div class="typeEnter">{{ scope.row.productCode }}：{{ scope.row.eventType }}</div>
        </template>
      </el-table-column>
      <el-table-column label="三要素" width="210">
        <template slot-scope="scope">
          <div class="typeEnter">姓名：{{ scope.row.name }}</div>
          <div class="typeEnter">手机号：{{ scope.row.phoneNo }}</div>
          <div class="typeEnter">idCard: {{ scope.row.idCard }}</div>
        </template>
      </el-table-column>
      <el-table-column prop="creditLimit" label="额度" width="70"></el-table-column>
      <el-table-column prop="resultType" label="结果" width="60"></el-table-column>
      <el-table-column label="请求与响应">
        <template slot-scope="scope">
          <div class="typeEnter">请求参数：{{ scope.row.request  | ellipsis }}</div>
          <div class="typeEnter">响应参数: {{ scope.row.response | ellipsis }}</div>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="pageTotal>0"
      :total="pageTotal"
      :page.sync="queryParam.pageNum"
      :limit.sync="queryParam.pageSize"
      @pagination="queryPage"
    />
  </div>
</template>
<script>

import {ellipsis, parseTime} from "../../../utils";

export default {
  data() {
    return {
      // 查询参数
      pageTotal: 0,
      queryParam: {
        productCode: '',
        eventType: '',
        name: '',
        phoneNo: '',
        idCard: '',
        creditLimit: '',
        resultType: '',
        pageNum: 1,
        pageSize: 10
      },
      tableData: []
    }
  },
  mounted() {
    this.pageList()
  },
  methods: {
    ellipsis,
    parseTime,
    queryPage() {
      var _this = this
      _this.pageList()
    },
    pageList() {
      var _this = this
      this.$api.eventPageList(_this.queryParam).then(res => {
        if (res.code === '00000') {
          _this.tableData = res.data.pageList
          _this.pageTotal = res.data.pageTotal
        } else {
          _this.$message(res.msg)
        }
      }).catch(e => {
        console.log('接口访问异常!')
      })
    }
  },
  filters: {
    ellipsis: (str) => ellipsis(str, 200)
  }
}
</script>
